def interpolation_search(arr, key):
    count = 0  # 初始化查找次数
    low, high = 0, len(arr) - 1
    while low < high:
        count += 1  # 每次循环查找次数加1
        if arr[low] == arr[high]:
            if arr[low] == key:
                print(f"查找次数为: {count}")
                return low
            else:
                print(f"查找次数为: {count}")
                return -1
        mid = low + (high - low) * (key - arr[low]) // (arr[high] - arr[low])
        if key < arr[mid]:
            high = mid - 1
        elif key > arr[mid]:
            low = mid + 1
        else:
            print(f"查找次数为: {count}")
            return mid
    if arr[low] == key:
        print(f"查找次数为: {count}")
        return low
    print(f"查找次数为: {count}")
    return -1

# 获取用户输入的数组元素，以空格分隔
input_str = input("请输入有序数组元素，以空格分隔: ")
arr = [int(x) for x in input_str.split()]

# 获取用户输入的目标值
key = int(input("请输入待查找元素: "))

result = interpolation_search(arr, key)
print(f"具体的 result 值是: {result}")